package com.ruoyi.business.controller;

import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.business.domain.InventoryClass;
import com.ruoyi.business.service.IInventoryClassService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

import java.util.Arrays;
import java.util.List;

/**
 * InventoryClassController
 *
 * @author liutietou
 * @since 1.0 2025-06-22
 */
@RestController
@RequestMapping("/business/InventoryClass")
public class InventoryClassController extends BaseController {
    @Autowired
    private IInventoryClassService inventoryClassService;

    /**
     * 查询InventoryClass列表
     */
  //  @PreAuthorize("@ss.hasPermi('business:InventoryClass:list')")
    @GetMapping("/list")
    public TableDataInfo list(InventoryClass inventoryClass) {
        Page<InventoryClass> page = inventoryClassService.findInventoryClassPage(inventoryClass);
        return getDataTable(page);
    }

    /**
     * 导出InventoryClass列表
     */
    @PreAuthorize("@ss.hasPermi('business:InventoryClass:export')")
    @Log(title = "InventoryClass", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(InventoryClass inventoryClass) {
        List<InventoryClass> list = inventoryClassService.findInventoryClassList(inventoryClass);
        ExcelUtil<InventoryClass> util = new ExcelUtil<>(InventoryClass.class);
        return util.exportExcel(list, "InventoryClass");
    }

    /**
     * 获取InventoryClass详细信息
     */
 //   @PreAuthorize("@ss.hasPermi('business:InventoryClass:query')")
    @GetMapping(value = "/{cinvccode}")
    public AjaxResult getInfo(@PathVariable("cinvccode") String cinvccode) {
        return AjaxResult.success(inventoryClassService.findById(cinvccode));
    }

}
